package com.twu.biblioteca;

import javax.swing.*;

import static javax.swing.JOptionPane.*;

/**
 * Created with IntelliJ IDEA.
 * User: nlima
 * Date: 1/25/13
 * Time: 2:33 PM
 * To change this template use File | Settings | File Templates.
 */
public class Library {
    private BookCollection bookCollection;

    public Library() {
        bookCollection = new BookCollection();
    }

    public String getWelcomeMessage() {
        return "Welcome";
    }

    public String[] getOptions() {

        String[] options = new String[3];
        options[0]="Reserve a book";
        options[1]="View a list of all the books";
        options[2]="Check their membership details";

        return options;
    }

    public String selectOption(int option) {
        if (option <= getOptions().length ){
            if (option == 2){
                return bookCollection.listBooks();

            }
            else if (option==3){
                return "Please talk to a Librarian. Thank you";
            }
        return "valid selection";
        }
        return "invalid option";
    }


    public String reservBook(String book) {
        BookCollection bookCollection1 = new BookCollection();

        for (int i=0;i<=bookCollection1.listBooks().length();i++){

            if(bookCollection1.listBooks().contains(book))

               return "valid reserv";

             }
               return "invalid reserv";
     }

    public String statusOfReserv(String name) {
        BookCollection bookCollection1 = new BookCollection();

        for (int i=0;i<=bookCollection1.listBooks().length();i++){

            if(bookCollection1.listBooks().contains(name))

                return "Thank You! Enjoy your Book";

            }
                return "Sorry we don't have that book yet";
    }

}
